﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace WCF
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    public class getData : IWCF
    {
        public PairComposite Add(PairComposite p1, PairComposite p2)
        {
            PairComposite result = new PairComposite();
            result.first = p1.first + p2.first;
            result.second = +p2.second;
            return result;
        }
        public UserComposite GetUser(Guid ID)
        {
            using(ASPNETDBEntities db = new ASPNETDBEntities())
            {
                try{
                    var name = (from i in db.aspnet_Users
                                      where i.UserId == ID
                                      select i.UserName).Single();
                    UserComposite UserComposite = new UserComposite();
                    UserComposite.Username = name;
                    var email = (from x in db.aspnet_Membership
                                 where x.UserId == ID
                                 select x.Email).Single();
                    UserComposite.Email = email;
                    return UserComposite;
                                        
                }
                catch{
                    return null;
                   
                }

            }

        }

    }
}
